home *** CD-ROM | disk | FTP | other *** search
/ Mac Magazin/MacEasy 34 / Mac Magazin and MacEasy Magazine CD - Issue 34.iso / Grafik & Text / Alpha ƒ / Tcl / Modes / latexMenu.tcl < prev    next >
Text File  |  1997-03-31  |  27KB  |  1,262 lines

  1. #############################################################################
  2. #############################################################################
  3. #
  4. # latexMenu.tcl (called from latex.tcl)
  5. #
  6. # LaTeX menu definitions and key bindings
  7. #
  8. #############################################################################
  9. #
  10. # Author:  Tom Scavo <trscavo@syr.edu>
  11. #
  12. #############################################################################
  13. #############################################################################
  14.  
  15. # The highest level menu macro, to be called initially or whenever 
  16. # the LaTeX menu must be rebuilt (as in 'shadowtexSig' in latex.tcl,
  17. # or 'toggleLaTeXMenus' below):
  18. proc buildLaTeXMenu {} {
  19.     global texSig texAppSig latexMenu
  20.     global useShortLaTeXMenu
  21.     global modifiedModeMenus
  22.     
  23.     set texAppMenuID(OzTeX) "•266"
  24.     set texAppMenuID(Textures) "•267"
  25.     set texAppMenuID(CMacTeX) "•272"
  26. #     set texAppMenuID(CMacTeX) "•273"
  27.     set texAppMenuID(DirectTeXPro) "•299"
  28.     if { [info exists texSig] && $texSig != "" } {
  29.         set supportedApps [array names texAppMenuID]
  30.         foreach app $supportedApps {
  31.             if { $texAppSig($app) == $texSig } {
  32.                 set latexMenu $texAppMenuID($app)
  33.                 break
  34.             }
  35.         }
  36.     }
  37.     menu -M TeX -n $latexMenu -m -p latexHelp [getLaTeXMenu]
  38.     markMenuItem {LaTeX Utilities} {Short LaTeX Menu} $useShortLaTeXMenu
  39.     lappend modifiedModeMenus TeX
  40.     return
  41. }
  42.  
  43. # Invoked by choosing "Short LaTeX Menu" on the "LaTeX Utilities" submenu:
  44. proc toggleLaTeXMenus {} {
  45.     global useShortLaTeXMenu modifiedVars
  46.     watchCursor
  47.     set useShortLaTeXMenu [expr 1 - $useShortLaTeXMenu]
  48.     lappend modifiedVars useShortLaTeXMenu
  49.     message {Rebuilding LaTeX menu…}
  50.     buildLaTeXMenu
  51.     message ""
  52. }
  53.  
  54. # Return a short menu or a long menu, depending on the value of
  55. # the global variable 'useShortLaTeXMenu':
  56. proc getLaTeXMenu {} {
  57.     global useShortLaTeXMenu
  58.     if {$useShortLaTeXMenu} {
  59.         return [concat \
  60.             [getLaTeXCommands] \
  61.           {{(-}} \
  62.           [getTextSubsubmenus] \
  63.           {{(-}} \
  64.           [getMathSubsubmenus] \
  65.         ]
  66.     } else {
  67.         return [concat \
  68.             [getLaTeXCommands] \
  69.           {{(-}} \
  70.             [getTextSubmenus] \
  71.             {{(-}} \
  72.             [getMathSubmenus] \
  73.         ]
  74.     }
  75. }
  76.  
  77. # Return generic LaTeX commands common to both menus:
  78. proc getLaTeXCommands {} {
  79.     return [list \
  80.         [typesetSubmenu] \
  81.         [gotoSubmenu] \
  82.         [latexUtilitiesSubmenu] \
  83.         "LaTeX Help" \
  84.         {(-} \
  85.         [documentsSubmenu] \
  86.         [pageLayoutSubmenu] \
  87.         [sectioningSubmenu] \
  88.     ]
  89. }
  90.  
  91. proc latexHelp {menu item} {
  92.     global HOME
  93.     edit -r "$HOME:Help:LaTeX Help"
  94. }
  95.  
  96. proc laTeXPalette {} {
  97.     global latexMenu
  98.     float -m $latexMenu -n LaTeX -M -1 -z TeX
  99. }
  100.  
  101. # Return the text submenus as a hierarchical submenu (for the short menu):
  102. proc getTextSubsubmenus {} {
  103.     set m [getTextSubmenus]
  104.     set mm [list menu -M TeX -n {Text Submenus} -m $m]
  105.     return [list $mm]
  106. }
  107.  
  108. # Return the math submenus as a hierarchical submenu (for the short menu):
  109. proc getMathSubsubmenus {} {
  110.     set m [getMathSubmenus]
  111.     set mm [list menu -M TeX -n {Math Submenus} -m $m]
  112.     return [list $mm]
  113. }
  114.  
  115. # Return the text submenus:
  116. proc getTextSubmenus {} {
  117.     return [list \
  118.         [textStyleSubmenu] \
  119.       [textSizeSubmenu] \
  120.       [internationalSubmenu] \
  121.       [environmentsSubmenu] \
  122.       [boxesSubmenu] \
  123.       [miscellaneousSubmenu] \
  124.     ]
  125. }
  126.  
  127. # Return the math submenus:
  128. proc getMathSubmenus {} {
  129.     return [list \
  130.         [mathModeSubmenu] \
  131.       [mathStyleSubmenu] \
  132.       [mathEnvironmentsSubmenu] \
  133.       [formulasSubmenu] \
  134.       [greekSubmenu] \
  135.       [binaryOperatorsSubmenu] \
  136.       [relationsSubmenu] \
  137.       [arrowsSubmenu] \
  138.       [dotsSubmenu] \
  139.       [symbolsSubmenu] \
  140.       [functionsSubmenu] \
  141.       [largeOperatorsSubmenu] \
  142.       [delimitersSubmenu] \
  143.       [mathAccentsSubmenu] \
  144.       [groupingSubmenu] \
  145.       [spacingSubmenu] \
  146.     ]
  147. }
  148.  
  149. #############################################################################
  150. #
  151. # Submenu definitions
  152. #
  153. #############################################################################
  154.  
  155. # Return the "Typeset" submenu.  If the current document belongs
  156. # to a TeX fileset, display the base filename throughout.
  157. #
  158. proc typesetSubmenu {} {
  159.     global mode
  160.     set currentWin [lindex [winNames -f] 0]
  161.     if { $currentWin == "" } {
  162.         return [minimalTypesetSubmenu]
  163.     } elseif { $mode == "TeX" } {
  164.         set currentDoc [file tail $currentWin]
  165.         # Process an untitled window:
  166.         if { [set num [winUntitled]] } {
  167.             if { $num > 1 } { set currentDoc "Untitled$num" }
  168.             # fall through
  169.         }
  170.     } else {
  171.         return [minimalTypesetSubmenu]
  172.     }
  173. #     set currentWin [lindex [winNames -f] 0]
  174. #     if { $currentWin == "" } {
  175. #         return [minimalTypesetSubmenu]
  176. #     } else {
  177. #         set currentDoc [file tail $currentWin]
  178. #         # Process an untitled window:
  179. #         if { [set num [winUntitled]] } {
  180. #             if { $num > 1 } { set currentDoc "Untitled$num" }
  181. #             # fall through
  182. #         } else {
  183. #             set ext [file extension $currentWin]
  184. #             if { [lsearch -exact {.tex .ltx .dtx .ins} $ext] < 0 } {
  185. #                 return [minimalTypesetSubmenu]
  186. #             }
  187. #         }
  188. #     }
  189.     set docBasename [file rootname $currentDoc]
  190.     set projBasename $docBasename
  191.     set currentProj [isWindowInFileset $currentWin "tex"]
  192.     if {    $currentProj !=    "" } {
  193.         set currentDoc [file tail [texFilesetBaseName $currentProj]]
  194.         set docBasename [file rootname $currentDoc]
  195.     }
  196.     # Determine which menu items are dimmed:
  197.     foreach ext {DVI PS AUX IDX Selection} { set prefix$ext "" }
  198. #     if { [findAuxiliaryFile DVI] == "" } {
  199. #         set prefixDVI "("
  200. #     }
  201. #     if { [findAuxiliaryFile PS] == "" } {
  202. #         set prefixPS "("
  203. #     }
  204. #     if { [findAuxiliaryFile AUX] == "" } {
  205. #         set prefixAUX "("
  206. #     }
  207. #     if { [findAuxiliaryFile IDX] == "" } {
  208. #         set prefixIDX "("
  209. #     }
  210. #     if { ![isSelection] } {
  211. #         set prefixSelection "("
  212. #     }
  213.     return [list menu -M TeX -n Typeset -m -p typesetSubmenuFilter [list \
  214.         [list /TTypeset $currentDoc] \
  215.         [list <U<O/V${prefixDVI}View "$docBasename\.dvi"] \
  216.         [list <U<O/P${prefixDVI}Print "$docBasename\.dvi"] \
  217.         "(-" \
  218.         {<U<O/TTypeset Clipboard} \
  219.         [list ${prefixSelection}Typeset Selection] \
  220.         "(-" \
  221.         [list <S${prefixPS}Open "$docBasename\.ps"] \
  222.         [list <S${prefixDVI}dvips "$docBasename\.dvi"] \
  223.         [list ${prefixPS}View "$docBasename\.ps"] \
  224.         [list ${prefixPS}Print "$docBasename\.ps"] \
  225.         "(-" \
  226.         [list <SOpen "$docBasename\.bbl"] \
  227.         [list <S${prefixAUX}bibtex "$docBasename\.aux"] \
  228.         [list <E<SOpen "$docBasename\.ind"] \
  229.         [list <S${prefixIDX}makeindex "$docBasename\.idx"] \
  230.         "(-" \
  231.         [typesetOtherFilesSubmenu $docBasename $projBasename] \
  232.         "(-" \
  233.         {Remove Auxiliary Files…} \
  234.         {Remove Temporary Files} \
  235.         ]
  236.     ]
  237. }
  238. proc minimalTypesetSubmenu {} {
  239.     return [list menu -M TeX -n Typeset -m -p typesetSubmenuFilter [list \
  240.         [list /TTypeset…] \
  241.         "(-" \
  242.         {<U<O/TTypeset Clipboard} \
  243.         {Typeset Selection} \
  244.         ]
  245.     ]
  246. }
  247. # Return a submenu of LaTeX auxiliary files with basename $basename1,
  248. # except for the .aux file whose primary basename is $basename2.
  249. #
  250. proc typesetOtherFilesSubmenu { basename1 basename2 } {
  251.     return [list menu -M TeX -n {Other Files} -m -p typesetSubmenuFilter [list \
  252.         [list Open "$basename1\.log"] \
  253.         [concat <SOpen "$basename1\.aux "] \
  254.         [concat <SOpen "$basename2\.aux"] \
  255.         [list Open "$basename1\.toc"] \
  256.         [list Open "$basename1\.lof"] \
  257.         [list Open "$basename1\.lot"] \
  258.         [list Open "$basename1\.idx"] \
  259.         "(-" \
  260.         [list Open "$basename1\.blg"] \
  261.         [list Open "$basename1\.ilg"] \
  262.         "(-" \
  263.         {<U<O/OOpen Any TeX File…} \
  264.         ]
  265.     ]
  266. }
  267. proc typesetSubmenuFilter {submenu item} {
  268.     switch -regexp $item {
  269.         {Typeset Selection}  {set func "typesetSelection"}
  270.         {Typeset Clipboard}  {set func "typesetClipboard"}
  271.         "Typeset.*"  {set func "typeset"}
  272.         "View.*\.dvi$"  {set func {doTypesetCommand view DVI}}
  273.         "Print.*\.dvi$"  {set func {doTypesetCommand print DVI}}
  274.         "dvips.*\.dvi$"  {set func {doTypesetCommand dvips DVI}}
  275.         "View.*\.ps$"  {set func {doTypesetCommand view PS}}
  276.         "Print.*\.ps$"  {set func {doTypesetCommand print PS}}
  277.         "bibtex.*"  {set func {doTypesetCommand bibtex AUX}}
  278.         "makeindex.*"  {set func {doTypesetCommand makeindex IDX}}
  279.         "Open.*\.ps$"  {set func {doTypesetCommand open PS}}
  280.         "Open.*\.bbl$"  {set func {doTypesetCommand open BBL}}
  281.         "Open.*\.ind$"  {set func {doTypesetCommand open IND}}
  282.         "Open.*\.log$"  {set func {doTypesetCommand open LOG}}
  283.         "Open.*\.aux$"  {set func {doTypesetCommand open AUX 1}}
  284.         "Open.*\.aux $"  {set func {doTypesetCommand open AUX}}
  285.         "Open.*\.toc$"  {set func {doTypesetCommand open TOC}}
  286.         "Open.*\.lof$"  {set func {doTypesetCommand open LOF}}
  287.         "Open.*\.lot$"  {set func {doTypesetCommand open LOT}}
  288.         "Open.*\.idx$"  {set func {doTypesetCommand open IDX}}
  289.         "Open.*\.blg$"  {set func {doTypesetCommand open BLG}}
  290.         "Open.*\.ilg$"  {set func {doTypesetCommand open ILG}}
  291.         {Open Any TeX File}  {set func "openAnyTeXFile"}
  292.         {Remove Auxiliary Files}  {set func "removeAuxiliaryFiles"}
  293.         {Remove Temporary Files}  {set func "removeTemporaryFiles"}
  294.         default {set func $item}
  295.     }
  296.     eval $func
  297. }
  298.  
  299. # Return the "Goto" submenu:
  300. proc gotoSubmenu {} {
  301.     return {menu -M TeX -n Goto -m -p gotoSubmenuFilter {
  302.         "<U/SLaTeX"
  303.         "BibTeX"
  304.         "MakeIndex"
  305.         "(-"
  306.         {/cNext Tab Stop}
  307.         {<U/cPrev Tab Stop}
  308.         {<B/cnth Tab Stop…}
  309.         "(-"
  310.         {Next Command}
  311.         {Prev Command}
  312.         {Next Command Select}
  313.         {Prev Command Select}
  314.         {Next Command Select With Args}
  315.         {Prev Command Select With Args}
  316.         "(-"
  317.         {Next Environment}
  318.         {Prev Environment}
  319.         {Next Environment Select}
  320.         {Prev Environment Select}
  321.         "(-"
  322.         {Next Section}
  323.         {Prev Section}
  324.         {Next Section Select}
  325.         {Prev Section Select}
  326.         {Next Subsection}
  327.         {Prev Subsection}
  328.         {Next Subsection Select}
  329.         {Prev Subsection Select}
  330.         }
  331.     }
  332. }
  333. proc gotoSubmenuFilter {submenu item} {
  334.     switch $item {
  335.         "LaTeX"  {set func "latex"}
  336.         "BibTeX"  {set func "bibtex"}
  337.         "MakeIndex"  {set func "makeindex"}
  338.         {Next Tab Stop}  {set func "nextTabStop"}
  339.         {Prev Tab Stop}  {set func "prevTabStop"}
  340.         {nth Tab Stop}  {set func "nthTabStop"}
  341.         {Next Command}  {set func "nextCommand"}
  342.         {Prev Command}  {set func "prevCommand"}
  343.         {Next Command Select}  {set func "nextCommandSelect"}
  344.         {Prev Command Select}  {set func "prevCommandSelect"}
  345.         {Next Command Select With Args}  {set func "nextCommandSelectWithArgs"}
  346.         {Prev Command Select With Args}  {set func "prevCommandSelectWithArgs"}
  347.         {Next Environment}  {set func "nextEnvironment"}
  348.         {Prev Environment}  {set func "prevEnvironment"}
  349.         {Next Environment Select}  {set func "nextEnvironmentSelect"}
  350.         {Prev Environment Select}  {set func "prevEnvironmentSelect"}
  351.         {Next Section}  {set func "nextSection"}
  352.         {Prev Section}  {set func "prevSection"}
  353.         {Next Section Select}  {set func "nextSectionSelect"}
  354.         {Prev Section Select}  {set func "prevSectionSelect"}
  355.         {Next Subsection}  {set func "nextSubsection"}
  356.         {Prev Subsection}  {set func "prevSubsection"}
  357.         {Next Subsection Select}  {set func "nextSubsectionSelect"}
  358.         {Prev Subsection Select}  {set func "prevSubsectionSelect"}
  359.         default {set func $item}
  360.     }
  361.     eval $func
  362. }
  363.  
  364. # Return the "LaTeX Utilities" submenu:
  365. proc latexUtilitiesSubmenu {} {
  366.     return {menu -M TeX -n {LaTeX Utilities} -m -p latexUtilsSubmenuFilter {
  367.         {<U<O/CChoose Command…}
  368.         "(-"
  369.         {<I/cInsert Literal Tab}
  370.         {Insert Tab Stop}
  371.         "(-"
  372.         {<O/cDelete Tab Stops}
  373.         {Delete Comments}
  374.         "(-"
  375.         {Convert Quotes}
  376.         {Convert Dollar Signs}
  377.         "(-"
  378.         {Short LaTeX Menu}
  379.         }
  380.     }
  381. }
  382. proc latexUtilsSubmenuFilter {submenu item} {
  383.     switch $item {
  384.         {Choose Command}  {set func {chooseCommand [getLaTeXMenu]}}
  385.         {Insert Literal Tab}  {set func "insertLiteralTab"}
  386.         {Insert Tab Stop}  {set func "insertTabStop"}
  387.         {Insert Reference}  {set func "insertReference"}
  388.         {Delete Tab Stops}  {set func "deleteTabStops"}
  389.         {Delete Comments}  {set func "deleteComments"}
  390.         {Convert Quotes}  {set func "convertQuotes"}
  391.         {Convert Dollar Signs}  {set func "convertDollarSigns"}
  392.         {Short LaTeX Menu}  {set func "toggleLaTeXMenus"}
  393.         default {set func $item}
  394.     }
  395.     eval $func
  396. }
  397.  
  398. # Return the "Documents" submenu:
  399. proc documentsSubmenu {} {
  400.     return [list menu -M TeX -n Documents -m -p documentsSubmenuFilter [list \
  401.         {<U<O/NNew Document…} \
  402.         [insertDocumentSubmenu] \
  403.         "(-" \
  404.         "options…" \
  405.         "<B<I/Uusepackage" \
  406.         [packagesSubmenu] \
  407.         "(-" \
  408.         "filecontents…" \
  409.         {filecontents All} \
  410.         "(-" \
  411.         {Rebuild Documents Submenu} \
  412.         ]
  413.     ]
  414. }
  415. proc insertDocumentSubmenu {} {
  416.     return {menu -M TeX -n {Insert Document} -m -p documentsSubmenuFilter {
  417.         "article"
  418.         "report"
  419.         "book"
  420.         "letter"
  421.         "slides"
  422.         "other…"
  423.         }
  424.     }
  425. }
  426. proc documentsSubmenuFilter {submenu item} {
  427.     switch $item {
  428.         {New Document}  {set func "newLaTeXDocument"}
  429.         {article}  {set func "articleDocumentclass"}
  430.         {report}  {set func "reportDocumentclass"}
  431.         {book}  {set func "bookDocumentclass"}
  432.         {letter}  {set func "letterDocumentclass"}
  433.         {slides}  {set func "slidesDocumentclass"}
  434.         {other}  {set func "otherDocumentclass"}
  435.         {usepackage} {insertPackage ""; return}
  436.         {filecontents All} {set func "filecontentsAll"}
  437.         {Rebuild Documents Submenu}  {
  438.             global packagesSubmenuItems
  439.             set packagesSubmenuItems ""
  440.             message "Rebuilding the Documents submenu…"
  441.             eval [documentsSubmenu]
  442.             message ""
  443.             return
  444.         }
  445.         default {set func $item}
  446.     }
  447.     eval $func
  448. }
  449.  
  450. proc packagesSubmenu {} {
  451.     global TeXmodeVars
  452.     if { $TeXmodeVars(buildPkgsSubmenu) } {
  453.         global packagesSubmenuItems
  454.         if { ![info exists packagesSubmenuItems] || $packagesSubmenuItems == "" } {
  455.                 global latexPackages
  456.                 set folders [buildTeXSearchPath 0]
  457.                 # See DblClickAux.tcl for the definition of 'buildSubMenu':
  458.                 set packagesSubmenuItems \
  459.                     [buildSubMenu $folders "Packages" packageFilter latexPackages ".sty"]
  460.         }
  461.         return $packagesSubmenuItems
  462.     } else {
  463. #         if { [info exists packagesSubmenuItems] } {
  464.         catch {unset packagesSubmenuItems}
  465. #         }
  466.         return ""
  467.     }
  468. }
  469. proc packageFilter {submenu pkgName} {
  470.     global latexPackages
  471.     # See latexMacros.tcl for definition of 'insertPackage':
  472.     insertPackage [file tail [file rootname $latexPackages($submenu:$pkgName)]]
  473. }
  474.  
  475. # Return the "Page Layout" submenu:
  476. proc pageLayoutSubmenu {} {
  477.     return {menu -M TeX -n {Page Layout} -m {
  478.         "maketitle"
  479.         "(-"
  480.         "abstract"
  481.         "titlepage"
  482.         "(-"
  483.         "pagestyle…"
  484.         "thispagestyle…"
  485.         "pagenumbering…"
  486.         "(-"
  487.         "twocolumn"
  488.         "onecolumn"
  489.         }
  490.     }
  491. }
  492.  
  493. # Return the "Sectioning" submenu:
  494. proc sectioningSubmenu {} {
  495.     return {menu -M TeX -n Sectioning -m {
  496.         "part"
  497.         "chapter"
  498.         "section"
  499.         "subsection"
  500.         "subsubsection"
  501.         "paragraph"
  502.         "subparagraph"
  503.         "(-"
  504.         "appendix"
  505.         }
  506.     }
  507. }
  508.  
  509. # Return the "Text Style" submenu:
  510. proc textStyleSubmenu {} {
  511.     return {menu -M TeX -n {Text Style} -m {
  512.         "<S<B<I/Eemph"
  513.         "<S<U<B<I/Eem"
  514.         "<B<O/Uunderline"
  515.         "(-"
  516.         "<Supshape"
  517.         "<Stextup"
  518.         "<E<S<B<I/Itextit"
  519.         "<S<U<B<I/Iitshape"
  520.         "<E<S<B<I/Stextsl"
  521.         "<S<U<B<I/Sslshape"
  522.         "<E<S<B<I/Htextsc"
  523.         "<S<U<B<I/Hscshape"
  524.         "(-"
  525.         "<Smdseries"
  526.         "<Stextmd"
  527.         "<E<S<B<I/Btextbf"
  528.         "<S<U<B<I/Bbfseries"
  529.         "(-"
  530.         "<S<B<I/Rtextrm"
  531.         "<S<U<B<I/Rrmfamily"
  532.         "<E<S<B<I/Wtextsf"
  533.         "<S<U<B<I/Wsffamily"
  534.         "<E<S<B<I/Ytexttt"
  535.         "<S<U<B<I/Yttfamily"
  536.         "(-"
  537.         "<Snormalfont"
  538.         "<Stextnormal"
  539.         }
  540.     }
  541. }
  542.  
  543. # Return the "Text Size" submenu:
  544. # proc textSizeSubmenu {} {
  545. #     return {menu -M TeX -n {Text Size} -m {
  546. #         "<B<I/1tiny"
  547. #         "<B<I/2scriptsize"
  548. #         "<B<I/3footnotesize"
  549. #         "<B<I/4small"
  550. #         "<B<I/5normalsize"
  551. #         "<B<I/6large"
  552. #         "<B<I/7Large"
  553. #         "<B<I/8LARGE"
  554. #         "<B<I/9huge"
  555. #         "<B<I/0Huge"
  556. #         }
  557. #     }
  558. # }
  559. proc textSizeSubmenu {} {
  560.     return {menu -M TeX -n {Text Size} -m -p textSizeSubmenuFilter {
  561.         "<B<I/1tiny"
  562.         "<B<I/2scriptsize"
  563.         "<B<I/3footnotesize"
  564.         "<B<I/4small"
  565.         "<B<I/5normalsize"
  566.         "<B<I/6large"
  567.         "<B<I/7Large"
  568.         "<B<I/8LARGE"
  569.         "<B<I/9huge"
  570.         "<B<I/0Huge"
  571.         }
  572.     }
  573. }
  574. proc textSizeSubmenuFilter {menu item} {
  575.     $item
  576. }
  577.  
  578. proc internationalSubmenu {} {
  579.     return {menu -M TeX -n International -m -p internatSubmenuFilter {
  580.         {ò}
  581.         {ó}
  582.         {ô}
  583.         {ö}
  584.         {õ}
  585.         "(-"
  586.         {ç}
  587.         {œ}
  588.         {æ}
  589.         {å}
  590.         {ø}
  591.         "(-"
  592.         {Ç}
  593.         {Œ}
  594.         {Æ}
  595.         {Å}
  596.         {Ø}
  597.         "(-"
  598.         {ß}
  599.         {¡}
  600.         {¿}
  601.         }
  602.     }
  603. }
  604. proc internatSubmenuFilter {menu item} {
  605.     $item
  606. }
  607.  
  608. # Return the "Environments" submenu:
  609. proc environmentsSubmenu {} {
  610.     return {menu -M TeX -n Environments -m {
  611.         "<I/kitemize…"
  612.         "<U<I/kenumerate…"
  613.         "<B<I/kdescription…"
  614.         "thebibliography…"
  615.         "(-"
  616.         "<I/lslide"
  617.         "<U<I/loverlay"
  618.         "<B<I/lnote"
  619.         "(-"
  620.         "<I/mfigure"
  621.         "<U<I/mtable"
  622.         "<B<I/mtabular…"
  623.         "(-"
  624.         "<I/nverbatim"
  625.         "<U<I/nquote"
  626.         "<B<I/nquotation"
  627.         "verse"
  628.         "(-"
  629.         "<I/ocenter"
  630.         "<U<I/oflushleft"
  631.         "<B<I/oflushright"
  632.         "(-"
  633.         "<I/pgeneral…"
  634.         }
  635.     }
  636. }
  637.  
  638. # Return the "Boxes" submenu:
  639. proc boxesSubmenu {} {
  640.     return {menu -M TeX -n Boxes -m {
  641.         "<B<I/Mmbox"
  642.         "makebox"
  643.         "fbox"
  644.         "framebox"
  645.         "(-"
  646.         "newsavebox"
  647.         "sbox"
  648.         "savebox"
  649.         "usebox"
  650.         "(-"
  651.         "raisebox"
  652.         "(-"
  653.         "parbox"
  654.         "minipage"
  655.         "(-"
  656.         "rule"
  657.         }
  658.     }
  659. }
  660.  
  661. # Return the "Miscellaneous" submenu:
  662. proc miscellaneousSubmenu {} {
  663.     return {menu -M TeX -n Miscellaneous -m -p miscSubmenuFilter {
  664.         "<B<I/Vverb"
  665.         "<B<I/Ffootnote"
  666.         {<B<I/Nmarginal note}
  667.         "(-"
  668.         "<B<I/Llabel"
  669.         "<B<I/Xref"
  670.         "<B<I/Ppageref"
  671.         "<B<I/Ccite"
  672.         "<U<B<I/Cnocite"
  673.         "(-"
  674.         "<B<I/Jitem"
  675.         "(-"
  676.         "<B<I/'quotes"
  677.         {<U<B<I/'double quotes}
  678.         "(-"
  679.         "!…ellipsis"
  680.         "!–en-dash"
  681.         "!—em-dash"
  682.         {TeX logo}
  683.         {LaTeX logo}
  684.         {LaTeX2e logo}
  685.         "date"
  686.         "(-"
  687.         "!†dag"
  688.         "ddag"
  689.         {!§section mark}
  690.         {!¶paragraph mark}
  691.         "!©copyright"
  692.         "!£pounds"
  693.         }
  694.     }
  695. }
  696. proc miscSubmenuFilter {submenu item} {
  697.     switch $item {
  698.         {marginal note}  {set func "marginalNote"}
  699.         "item" {set func "insertItem"}
  700.         {double quotes}  {set func "dblQuotes"}
  701.         "ellipsis"  {set func "ldots"}
  702.         {TeX logo}  {set func "texLogo"}
  703.         {LaTeX logo}  {set func "latexLogo"}
  704.         {LaTeX2e logo}  {set func "latex2eLogo"}
  705.         "date" {set func "today"}
  706.         {section mark}  {set func "sectionMark"}
  707.         {paragraph mark}  {set func "paragraphMark"}
  708.         default {set func $item}
  709.     }
  710.     eval $func
  711. }
  712.  
  713. # Return a "Math Modes" submenu (called below and in latexKeys.tcl):
  714. proc mathModeSubmenu {} {
  715.     global TeXmodeVars
  716.     if {$TeXmodeVars(useDollarSigns)} then {
  717.         bind '4' <zc> texMath "TeX"
  718.         bind '4' <zoc> texDisplaymath "TeX"
  719.         return {menu -M TeX -n {Math Modes} -m -p mathModeSubmenuFilter {
  720.             {<B<O/MTeX math}
  721.             {<B<I<O/MTeX displaymath}
  722.             "(-"
  723.             {LaTeX math}
  724.             {LaTeX displaymath}
  725.             }
  726.         }
  727.     } else {
  728.         bind '4' <zc> latexMath "TeX"
  729.         bind '4' <zoc> latexDisplaymath "TeX"
  730.         return {menu -M TeX -n {Math Modes} -m -p mathModeSubmenuFilter {
  731.             {TeX math}
  732.             {TeX displaymath}
  733.             "(-"
  734.             {<B<O/MLaTeX math}
  735.             {<B<I<O/MLaTeX displaymath}
  736.             }
  737.         }
  738.     }
  739. }
  740. proc mathModeSubmenuFilter {submenu item} {
  741.     switch $item {
  742.         {TeX math}  {set func "texMath"}
  743.         {TeX displaymath}  {set func "texDisplaymath"}
  744.         {LaTeX math}  {set func "latexMath"}
  745.         {LaTeX displaymath}  {set func "latexDisplaymath"}
  746.         default {set func $item}
  747.     }
  748.     eval $func
  749. }
  750.  
  751. # Return the "Math Style" submenu:
  752. proc mathStyleSubmenu {} {
  753.     return {menu -M TeX -n {Math Style} -m {
  754.         "<B<I<O/Imathit"
  755.         "<B<I<O/Rmathrm"
  756.         "<B<I<O/Bmathbf"
  757.         "<B<I<O/Wmathsf"
  758.         "<B<I<O/Ymathtt"
  759.         "<B<I<O/Cmathcal"
  760.         "(-"
  761.         "<B<I<O/Ddisplaystyle"
  762.         "<B<I<O/Ttextstyle"
  763.         "<B<I<O/Sscriptstyle"
  764.         "scriptscriptstyle"
  765.         }
  766.     }
  767. }
  768.  
  769. # Return the "Math Environments" submenu:
  770. proc mathEnvironmentsSubmenu {} {
  771.     return {menu -M TeX -n {Math Environments} -m -p mathEnvsSubmenuFilter {
  772.         "<I/imath"
  773.         "(-"
  774.         "<U<I/idisplaymath"
  775.         "<B<I/iequation"
  776.         "(-"
  777.         "<U<I/jeqnarray*…"
  778.         "<B<I/jeqnarray…"
  779.         "(-"
  780.         "<I/jarray…"
  781.         "(-"
  782.         "<I/pgeneral…"
  783.         }
  784.     }
  785. }
  786. proc mathEnvsSubmenuFilter {submenu item} {
  787.     switch $item {
  788.         "array"  {set func "myArray"}
  789.         "eqnarray\*"  {set func "eqnarrayStar"}
  790.         default {set func $item}
  791.     }
  792.     eval $func
  793. }
  794.  
  795. # Return the "Formulas" submenu:
  796. proc formulasSubmenu {} {
  797.     return {menu -M TeX -n Formulas -m -p formulasSubmenuFilter {
  798.         "subscript"
  799.         "superscript"
  800.         "(-"
  801.         "<B<O/Ffrac"
  802.         {<B<O/Rsqrt}
  803.         {nth root}
  804.         "(-"
  805.         {<B<O/1one parameter…}
  806.         {<B<O/2two parameters…}
  807.         }
  808.     }
  809. }
  810. proc formulasSubmenuFilter {submenu item} {
  811.     switch $item {
  812.         {frac}  {set func "fraction"}
  813.         {sqrt}  {set func "squareRoot"}
  814.         {nth root}  {set func "nthRoot"}
  815.         {one parameter}  {set func "oneParameter"}
  816.         {two parameters}  {set func "twoParameters"}
  817.         default {set func $item}
  818.     }
  819.     eval $func
  820. }
  821.  
  822. # Return the "Greek" submenu:
  823. proc greekSubmenu {} {
  824.     return {menu -M TeX -n Greek -m {
  825.         "alpha"
  826.         "beta"
  827.         "<SGamma"
  828.         "<Sgamma"
  829.         "<E<SDelta"
  830.         "<Sdelta"
  831.         "epsilon"
  832.         "zeta"
  833.         "eta"
  834.         "<STheta"
  835.         "<Stheta"
  836.         "iota"
  837.         "kappa"
  838.         "<SLambda"
  839.         "<Slambda"
  840.         "mu"
  841.         "nu"
  842.         "<SXi"
  843.         "<Sxi"
  844.         "omicron"
  845.         "<SPi"
  846.         "<Spi"
  847.         "rho"
  848.         "<SSigma"
  849.         "<Ssigma"
  850.         "tau"
  851.         "<SUpsilon"
  852.         "<Supsilon"
  853.         "<E<SPhi"
  854.         "<Sphi"
  855.         "chi"
  856.         "<SPsi"
  857.         "<Spsi"
  858.         "<E<SOmega"
  859.         "<Somega"
  860.         "(-"
  861.         "varepsilon"
  862.         "vartheta"
  863.         "varpi"
  864.         "varrho"
  865.         "varsigma"
  866.         "varphi"
  867.         }
  868.     }
  869. }
  870.  
  871. # Return the "Binary Operators" submenu:
  872. proc binaryOperatorsSubmenu {} {
  873.     return {menu -M TeX -n {Binary Operators} -m {
  874.         "!±pm"
  875.         "mp"
  876.         "times"
  877.         "!÷div"
  878.         "ast"
  879.         "star"
  880.         "circ"
  881.         "bullet"
  882.         "cdot"
  883.         "cap"
  884.         "cup"
  885.         "uplus"
  886.         "sqcap"
  887.         "sqcup"
  888.         "vee"
  889.         "wedge"
  890.         "setminus"
  891.         "(-"
  892.         "diamond"
  893.         "bigtriangleup"
  894.         "bigtriangledown"
  895.         "triangleleft"
  896.         "triangleright"
  897.         "lhd"
  898.         "rhd"
  899.         "unlhd"
  900.         "unrhd"
  901.         "(-"
  902.         "oplus"
  903.         "ominus"
  904.         "otimes"
  905.         "oslash"
  906.         "odot"
  907.         "(-"
  908.         "bigcirc"
  909.         "dagger"
  910.         "ddagger"
  911.         "amalg"
  912.         "wr"
  913.         }
  914.     }
  915. }
  916.  
  917. # Return the "Relations" submenu:
  918. proc relationsSubmenu {} {
  919.     return {menu -M TeX -n Relations -m -p relationsSubmenuFilter {
  920.         "<S!≥geq"
  921.         "<S!≤leq"
  922.         "<E<Ssucc"
  923.         "<Sprec"
  924.         "<E<Ssucceq"
  925.         "<Spreceq"
  926.         "<E<S!»gg"
  927.         "<S!«ll"
  928.         "<E<Ssupset"
  929.         "<Ssubset"
  930.         "<E<Ssupseteq"
  931.         "<Ssubseteq"
  932.         "<E<Ssqsupset"
  933.         "<Ssqsubset"
  934.         "<E<Ssqsupseteq"
  935.         "<Ssqsubseteq"
  936.         "<E<Sni"
  937.         "<Sin"
  938.         "<E<Sdashv"
  939.         "<Svdash"
  940.         "(-"
  941.         "equiv"
  942.         "sim"
  943.         "simeq"
  944.         "asymp"
  945.         "!≈approx"
  946.         "cong"
  947.         "!≠neq"
  948.         "doteq"
  949.         "propto"
  950.         "(-"
  951.         "models"
  952.         "perp"
  953.         "mid"
  954.         "parallel"
  955.         "bowtie"
  956.         "join"
  957.         "smile"
  958.         "frown"
  959.         }
  960.     }
  961. }
  962. proc relationsSubmenuFilter {submenu item} {
  963.     switch $item {
  964.         {join}  {set func "myJoin"}
  965.         {ll}  {set func "myLl"}
  966.         default {set func $item}
  967.     }
  968.     eval $func
  969. }
  970.  
  971. # Return the "Arrows" submenu:
  972. proc arrowsSubmenu {} {
  973.     return {menu -M TeX -n Arrows -m -p arrowsSubmenuFilter {
  974.         "<SLeftarrow"
  975.         "<Sleftarrow"
  976.         "<E<SRightarrow"
  977.         "<Srightarrow"
  978.         "<E<SLeftrightarrow"
  979.         "<Sleftrightarrow"
  980.         "<E<SLongleftarrow"
  981.         "<Slongleftarrow"
  982.         "<E<SLongrightarrow"
  983.         "<Slongrightarrow"
  984.         "<E<SLongleftrightarrow"
  985.         "<Slongleftrightarrow"
  986.         "(-"
  987.         "<SUparrow"
  988.         "<Suparrow"
  989.         "<E<SDownarrow"
  990.         "<Sdownarrow"
  991.         "<E<SUpdownarrow"
  992.         "<Supdownarrow"
  993.         "(-"
  994.         "mapsto"
  995.         "longmapsto"
  996.         "leadsto"
  997.         "(-"
  998.         "leftharpoonup"
  999.         "rightharpoonup"
  1000.         "leftharpoondown"
  1001.         "rightharpoondown"
  1002.         "rightleftharpoons"
  1003.         "hookleftarrow"
  1004.         "hookrightarrow"
  1005.         "nearrow"
  1006.         "searrow"
  1007.         "swarrow"
  1008.         "nwarrow"
  1009.         }
  1010.     }
  1011. }
  1012.  
  1013. proc arrowsSubmenuFilter {submenu item} {
  1014.     $item
  1015. }
  1016.  
  1017. # Return the "Dots" submenu:
  1018. proc dotsSubmenu {} {
  1019.     return {menu -M TeX -n Dots -m {
  1020.         "bullet"
  1021.         "cdot"
  1022.         "(-"
  1023.         "ldots"
  1024.         "cdots"
  1025.         "vdots"
  1026.         "ddots"
  1027.         }
  1028.     }
  1029. }
  1030.  
  1031. # Return the "Symbols" submenu:
  1032. proc symbolsSubmenu {} {
  1033.     return {menu -M TeX -n Symbols -m {
  1034.         "aleph"
  1035.         "hbar"
  1036.         "imath"
  1037.         "jmath"
  1038.         "ell"
  1039.         "wp"
  1040.         "Re"
  1041.         "Im"
  1042.         "mho"
  1043.         "(-"
  1044.         "angle"
  1045.         "backslash"
  1046.         "bot"
  1047.         "emptyset"
  1048.         "exists"
  1049.         "forall"
  1050.         "!∞infty"
  1051.         "nabla"
  1052.         "!¬neg"
  1053.         "!∂partial"
  1054.         "prime"
  1055.         "!√surd"
  1056.         "top"
  1057.         "(-"
  1058.         "Box"
  1059.         "Diamond"
  1060.         "triangle"
  1061.         "clubsuit"
  1062.         "diamondsuit"
  1063.         "heartsuit"
  1064.         "spadesuit"
  1065.         "(-"
  1066.         "flat"
  1067.         "natural"
  1068.         "sharp"
  1069.         }
  1070.     }
  1071. }
  1072.  
  1073. # Return the "Functions" submenu:
  1074. proc functionsSubmenu {} {
  1075.     return {menu -M TeX -n Functions -m {
  1076.         "arccos"
  1077.         "arcsin"
  1078.         "arctan"
  1079.         "arg"
  1080.         "cos"
  1081.         "cosh"
  1082.         "cot"
  1083.         "coth"
  1084.         "csc"
  1085.         "deg"
  1086.         "det"
  1087.         "dim"
  1088.         "exp"
  1089.         "gcd"
  1090.         "hom"
  1091.         "inf"
  1092.         "ker"
  1093.         "lg"
  1094.         "<B<O/Llim"
  1095.         "liminf"
  1096.         "limsup"
  1097.         "ln"
  1098.         "log"
  1099.         "max"
  1100.         "min"
  1101.         "Pr"
  1102.         "sec"
  1103.         "sin"
  1104.         "sinh"
  1105.         "sup"
  1106.         "tan"
  1107.         "tanh"
  1108.         "(-"
  1109.         "bmod"
  1110.         "pmod"
  1111.         }
  1112.     }
  1113. }
  1114.  
  1115. # Return the "Large Operators" submenu:
  1116. proc largeOperatorsSubmenu {} {
  1117.     return {menu -M TeX -n {Large Operators} -m {
  1118.         "<B<O/Ssum"
  1119.         "<B<O/Pprod"
  1120.         "coprod"
  1121.         "<B<O/Iint"
  1122.         "oint"
  1123.         "(-"
  1124.         "bigcup"
  1125.         "bigcap"
  1126.         "bigsqcup"
  1127.         "bigvee"
  1128.         "bigwedge"
  1129.         "bigodot"
  1130.         "bigotimes"
  1131.         "bigoplus"
  1132.         "biguplus"
  1133.         }
  1134.     }
  1135. }
  1136.  
  1137. # Return the "Delimiters" submenu:
  1138. proc delimitersSubmenu {} {
  1139.     return {menu -M TeX -n Delimiters -m -p delimitersSubmenuFilter {
  1140.         "parentheses"
  1141.         "brackets"
  1142.         "braces"
  1143.         {vertical bars}
  1144.         {other delims…}
  1145.         "(-"
  1146.         {half-open interval}
  1147.         {half-closed interval}
  1148.         "(-"
  1149.         {<Smulti-line big parentheses}
  1150.         {<Sbig parentheses}
  1151.         {<E<Smulti-line big brackets}
  1152.         {<Sbig brackets}
  1153.         {<E<Smulti-line big braces}
  1154.         {<Sbig braces}
  1155.         {<E<Smulti-line big vertical bars}
  1156.         {<Sbig vertical bars}
  1157.         {<E<Sother multi-line big delims…}
  1158.         {<Sother big delims…}
  1159.         "(-"
  1160.         {<Smulti-line big left brace}
  1161.         {<Sbig left brace}
  1162.         {<E<Sother multi-line mixed big delims…}
  1163.         {<Sother mixed big delims…}
  1164.         }
  1165.     }
  1166. }
  1167. proc delimitersSubmenuFilter {submenu item} {
  1168.     switch $item {
  1169.         {vertical bars}  {set func "absoluteValue"}
  1170.         {other delims}  {set func "otherDelims"}
  1171.         {half-open interval}  {set func "half-openInterval"}
  1172.         {half-closed interval}  {set func "half-closedInterval"}
  1173.         {big parentheses}  {set func "bigParens"}
  1174.         {multi-line big parentheses}  {set func "multiBigParens"}
  1175.         {big brackets}  {set func "bigBrackets"}
  1176.         {multi-line big brackets}  {set func "multiBigBrackets"}
  1177.         {big braces}  {set func "bigBraces"}
  1178.         {multi-line big braces}  {set func "multiBigBraces"}
  1179.         {big vertical bars}  {set func "bigAbsValue"}
  1180.         {multi-line big vertical bars}  {set func "multiBigAbsValue"}
  1181.         {other big delims}  {set func "otherBigDelims"}
  1182.         {other multi-line big delims}  {set func "otherMultiBigDelims"}
  1183.         {big left brace}  {set func "bigLeftBrace"}
  1184.         {multi-line big left brace}  {set func "multiBigLeftBrace"}
  1185.         {other mixed big delims}  {set func "otherMixedBigDelims"}
  1186.         {other multi-line mixed big delims}  {set func "otherMultiMixedBigDelims"}
  1187.         default {set func $item}
  1188.     }
  1189.     eval $func
  1190. }
  1191.  
  1192. # Return the "Math Accents" submenu:
  1193. proc mathAccentsSubmenu {} {
  1194.     return {menu -M TeX -n {Math Accents} -m {
  1195.         "<B<O/Aacute"
  1196.         "<B<O/Bbar"
  1197.         "breve"
  1198.         "<B<O/Ccheck"
  1199.         "<B<O/Ddot"
  1200.         "ddot"
  1201.         "<B<O/Ggrave"
  1202.         "<B<O/Hhat"
  1203.         "<B<O/Ttilde"
  1204.         "<B<O/Vvec"
  1205.         "(-"
  1206.         "widehat"
  1207.         "widetilde"
  1208.         "(-"
  1209.         "imath"
  1210.         "jmath"
  1211.         }
  1212.     }
  1213. }
  1214.  
  1215. # Return the "Grouping" submenu:
  1216. proc groupingSubmenu {} {
  1217.     return {menu -M TeX -n Grouping -m {
  1218.         "<B<O/Uunderline"
  1219.         "<B<O/Ooverline"
  1220.         "<B<I<O/Uunderbrace"
  1221.         "<B<I<O/Ooverbrace"
  1222.         "(-"
  1223.         "overrightarrow"
  1224.         "overleftarrow"
  1225.         "(-"
  1226.         "stackrel"
  1227.         }
  1228.     }
  1229. }
  1230.  
  1231. # Return the "Spacing" submenu:
  1232. proc spacingSubmenu {} {
  1233.     return {menu -M TeX -n Spacing -m -p spacingSubmenuFilter {
  1234.         {neg thin}
  1235.         "thin"
  1236.         "medium"
  1237.         "thick"
  1238.         "(-"
  1239.         "quad"
  1240.         "qquad"
  1241.         "(-"
  1242.         "hspace"
  1243.         "vspace"
  1244.         "(-"
  1245.         "hfill"
  1246.         "vfill"
  1247.         "(-"
  1248.         "smallskip"
  1249.         "medskip"
  1250.         "bigskip"
  1251.         }
  1252.     }
  1253. }
  1254. proc spacingSubmenuFilter {submenu item} {
  1255.     switch $item {
  1256.         {neg thin}  {set func "negThin"}
  1257.         default {set func $item}
  1258.     }
  1259.     eval $func
  1260. }
  1261.  
  1262.